<div class="modal fade " id="maintainProductModal"  role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">主责投资经理维护</h3>
            </div>
            <form class="form-horizontal" role="form" id="maintainProductForm"  method="post"  enctype="multipart/form-data">
                <div class="box-body">                  
                    <div class="form-group">
                       <input id="id" name="id" type="text" disabled="disabled" class="form-control" style="display:none;">
                        
                        <label class="col-sm-3 control-label" for="productZTBHLabel">账套号</label>
                        <div class="col-sm-3">
                            <input id="productZtbh" name="productZtbh" type="text" class="form-control"
                                   maxlength="4" onblur= "if( /[^\d]/g.test(this.value)){toastr['error']('账套号只能输入4位整数', '提示');}">
                        </div>
                        <label class="col-sm-3 control-label" for=tgEmailLabel">评分时间</label>
                        <div class="col-sm-3">
                            <input id="periodTime" name="periodTime" type="text" class="form-control"    minlength="6" maxlength="6">
                        </div>
                    </div>
                    <div class="form-group">
                       <label class="col-sm-3 control-label" for="productCodeLabel">主责投资经理账号</label>
                        <div class="col-sm-3">
                            <input id="manager" name="manager" type="text" class="form-control"
                                 >
                        </div>  
                          <label class="col-sm-3 control-label" for=tgEmailLabel">主责投资经理姓名</label>
                        <div class="col-sm-3">
                            <input id="managerName" name="managerName" type="text" class="form-control"    minlength="6" maxlength="6"  readonly="true">
                        </div>                     
                    </div> 
                    <div class="form-group">
                       <label class="col-sm-3 control-label" for="productCodeLabel">主责投资经理类型</label>
                        <div class="col-sm-3">                          
                              <select id="managerType" name="managerType" class=" form-control"
                                                        style="width: 90%">
                                                    <option value="-1">请选择</option>
                                                    <option value="固收">固收</option>
                                                    <option value="权益">权益</option>                                           
                               </select>
                        </div>                                          
                    </div>  
                </div>
                <div class="box-footer">
                    <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary pull-right" onclick="saveProduct1()">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<#include "../public/js.ftl" >
<#include "../public/css.ftl">
<script src="/js/common.js"></script>
<script>
    function maintainProductInit() {
        //初始化产品维护画面        
            $("#id").val("");
        $("#productZtbh").val("");
       //  $("#productZtbh").attr("disabled","");
        $('#productZtbh').removeAttr("disabled");
        $("#periodTime").val("");
        $('#periodTime').removeAttr("disabled");
        $("#manager").val("");
        $("#managerName").val("");
        $("#managerType").val("-1");
        
    }

    function modifyProductInit(data) {
        //查询数据设置到修改画面对应栏位
           $("#id").val(data.id);
   
           $("#productZtbh").val(data.productZtbh);
           $("#productZtbh").attr("disabled","disabled");
           $("#periodTime").val(data.periodTime);
           $("#periodTime").attr("disabled","disabled");
           $("#manager").val(data.manager);
           $("#managerName").val(data.managerName);
           $("#managerType").val(data.managerType);
    }

    function saveProduct1(){  
    	
    	
        var id = $("#id").val();
        
        var manager = $("#manager").val();
        
        var managerType = $("#managerType").val();
        
      //  alert(managerType);
      
      
        var productZtbh = $("#productZtbh").val();
        
        var periodTime = $("#periodTime").val();
        //去除空格
        manager = strTrim(manager);
        productZtbh = strTrim(productZtbh);
        periodTime = strTrim(periodTime);
		
        if (manager == "") {
            toastr['error']("主责投资经理账号不能为空", '异常');
            return;
        }
         if (managerType == "-1") {
            toastr['error']("主责投资经理类型不能为空", '异常');
            return;
        }
        if (productZtbh == "") {
            toastr['error']("账套编号不能为空", '异常');
            return;
        }
        if (periodTime == "") {
            toastr['error']("评分时间不能为空", '异常');
            return;
        }

        //检查产品名称长度不能超过100个字符
        //var length = strlen(productName);
       // if (length > 100) {
        //    toastr['error']("产品名称长度不能超过100个字符", '异常');
       //     return;
       // }

     
        //账户号     
        if (productZtbh != "") {
            if( /[^\d]/g.test(productZtbh)){
                toastr['error']("账户号只能输入整数", '提示');
                return;
            }
            //检查账户号合法位数是否为4位整数
            if(productZtbh < 1000 || productZtbh > 9999){
                toastr['error']("账户号只能输入4位整数", '提示');
                return;
            }
        }
        
          //评分时间   
        if (periodTime != "") {
            if( /[^\d]/g.test(periodTime)){
                toastr['error']("评分时间只能输入整数", '提示');
                return;
            }
            //检查账户号合法位数是否为6位整数
            if(periodTime > 205001 || periodTime <200001){
                toastr['error']("评分时间只能输入6位整数", '提示');
                return;
            }
        }     
     

        var data = {  
            id : id,          
            productZtbh : productZtbh,          
            periodTime : periodTime,
            manager : manager,
            managerType : managerType
        };
        var url;
        if(id == "") 
         url = "/manager/add";
        else 
         url = "/manager/modify";

        postReq(url, data, function (result) {
            if (result.success) {
                maintainProductInit();
                $("#productTable111").bootstrapTable("refresh");
                $("#maintainProductModal").modal("hide");
                toastr['success']('保存成功', '提示');
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>
